<?php
require_once "ApplicationException.php";

final class SMSMailer {

    /*
     * Sends an SMS to a mobile number through a URL.
     */
    public static function sendSMS($userName, $mobileNumber, $message) {

        $client = new HTTP_Client();
        $response = null;

        $paramArray = array();

        // @warren: is $paramArray['random'] really necessary? if yes please
        // include as one of the parameters of sendSMS()
        $paramArray['random'] = time();

        $paramArray['fbuserid'] = $userName;
        
        // What is the valid mobile number format for this one?
        $paramArray['mobilenum'] = $mobileNumber;

        $paramArray['message'] = $message;

        $url = "http://funmobile.onehomebase.com";

        try {
            $returncode = $client->get($url,$paramArray);
            $output = $client->currentResponse();
            $response = $output['body'];
        } catch (Exception $e) {
            throw new ApplicationException($e->getMessage());
        }
        
        // return the response
        return $response;
        
    }
}
?>
